package com.boyon.common.session;

import com.boyon.common.domain.UserSession;
import com.boyon.common.status.Constant;
import com.boyon.common.variable.LocalVariable;

/**
 * ClassName:SessionManager <br/>
 * Function: session管理类. <br/>
 * Date: 2018年4月3日 上午10:59:02 <br/>
 * 
 * @author sunshulin
 * @version
 * @since JDK 1.8
 * @see
 */
public class SessionManager {

	/**
	 * 
	 * getUserSession:获取当前用户信息. <br/>
	 * 
	 * @author sunshulin
	 * @return
	 * @since JDK 1.8
	 */
	public static UserSession getUserSession() {
		UserSession userSession = LocalVariable.get(Constant.SESSION_USER);
		return userSession;
	}

	/**
	 * 
	 * setUserSession:设置用户session. <br/>
	 * 
	 * @author sunshulin
	 * @param userSession
	 * @since JDK 1.8
	 */
	public static void setUserSession(UserSession userSession) {
		LocalVariable.set(Constant.SESSION_USER, userSession);
	}

	/**
	 * 
	 * set:设置变量. <br/>
	 * 
	 * @author sunshulin
	 * @param key
	 * @param value
	 * @since JDK 1.8
	 */
	public static <T> void set(String key, T value) {
		LocalVariable.set(key, value);
	}

	/**
	 * 
	 * get:获取变量. <br/>
	 * 
	 * @author sunshulin
	 * @param key
	 * @return
	 * @since JDK 1.8
	 */
	public static <T> T get(String key) {
		return LocalVariable.get(key);
	}
}
